package com.scau.dao.Impl;

import java.util.List;

import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;

import com.scau.dao.CommentDao;
import com.scau.dao.MessageDao;
import com.scau.mapper.MessageMapper;
import com.scau.mapper.MessagecommentMapper;
import com.scau.pojo.Message;
import com.scau.pojo.Messagecomment;
import com.scau.util.SqlSessionFactoryUtil;

@Repository
public class CommentDaoImpl implements CommentDao{
	
	SqlSession comment = SqlSessionFactoryUtil.getSession();
	MessagecommentMapper commentMapper=comment.getMapper(MessagecommentMapper.class);
	

	@Override
	public List<Messagecomment> query(Integer msId) {
		return commentMapper.selectCommentBymsId(msId);
	}


	@Override
	public int delComment(int commentId) {
		return commentMapper.deleteByPrimaryKey(commentId);
	}


	@Override
	public int delCommentByMsId(int msId) {
		return commentMapper.deleteByMsId(msId);
	}


	@Override
	public int updateCommentById(Messagecomment comment) {
		return commentMapper.updateByPrimaryKeySelective(comment);
	}


	@Override
	public int getCommentCount(int msId) {
		return commentMapper.countByExample(msId);
	}


	@Override
	public int addComment(Messagecomment comment) {
		return commentMapper.insertSelective(comment);
	}
	
}
